package Form;

//REMOVE WORDINGS from labels

import javax.swing.BorderFactory;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JFrame;

import Control.*;
import Entity.User;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.Date;
import java.sql.ResultSet;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.awt.Color;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JPasswordField;

public class Customer_UpdateCustomerProfile extends JPanel {
	
	private JLabel lblCustomerProfile;
	private JButton btnUpdateProfile;
	
	//Individual 
	private JPanel pn_ind;
	
	private JLabel lbl_iName;
	private JLabel lbl_iNric;
	private JLabel lbl_iGender;
	private JLabel lbl_iRace;
	private JLabel lbl_iResidentialAdd;
	private JLabel lbl_iEmail;
	private JLabel lbl_iUsername;
	private JLabel lbl_iContactNum;
	private JLabel lbl_iDOB;
	
	private JLabel iName;
	private JLabel iUsername;
	private JLabel iNric;
	private JLabel iGender;
	private JLabel iRace;
	private JTextField iEmail;
	private JTextField iContactNum;
	private JTextField iAddress;
	private JLabel iDOB;
	
	public JFrame frame;
	
	
	//Corporate 
	private JPanel pn_corp;
	
	private JLabel lbl_cName;
	private JLabel lbl_iPassword;
	private JLabel lbl_cUsername;
	private JLabel lbl_cPassword;
	private JLabel lbl_cRegNum;
	private JLabel lbl_cAddress;
	private JLabel lbl_cEmail;
	private JLabel lbl_cContactNum;

	
	private JLabel cName;
	private JLabel cUsername;
	private JLabel cRegNum;
	private JTextField cAddress;
	private JTextField cEmail;
	private JTextField cContactNum;
	
	private Customer_UpdateCustomerProfile parser;
	private Customer_Controller control;
	
	public User u = new User();
	private JPanel pn_ChangePwd;
	private JLabel lblCurrentPassowrd;
	private JLabel lblNewPwd;
	private JLabel lblConfirmPwd;
	private JPasswordField PF_CurrentPwd;
	private JPasswordField PF_NewPwd;
	private JPasswordField PF_CfmPwd;
	private JButton Bn_UpdatePwd;
	private JButton btnUpdateCPsd;
	private JButton bn_UpdateiPwd;
	private JButton bn_cancelPwd;
	private JButton btnDeleteAccount;
	private String Password;
	
	public  Customer_UpdateCustomerProfile getParser() {
		return parser;
	}
	
	public void setParser( Customer_UpdateCustomerProfile parser) {
		this.parser = parser;
	}
	
	public Customer_Controller getControl(){
		return control;
	}

	public void setControl (Customer_Controller control) {
		this.control = control; 
	}
	
	
	public Customer_UpdateCustomerProfile(User u) {
		this.setParser(parser);
		this.setControl(new Customer_Controller(this));
		
		setLayout(null);
		setPreferredSize(new Dimension(524, 554));
		add(getPn_ChangePwd());
		add(getLblCustomerProfile());
		add(getPn_ind());
		add(getBtnUpdateProfile());
		
		this.u = u;
		add(getPn_corp());
		add(getBtnDeleteAccount());
		if(u.getCustomerUserType().equals("CORPORATE")){
			initializeCorp();
			pn_ind.setVisible(false);
			pn_corp.setVisible(true);
			pn_ChangePwd.setVisible(false); 
			 
			
		}else if(u.getCustomerUserType().equals("INDIVIDUAL")){
			initializeIndividual();
			pn_ind.setVisible(true);
			pn_corp.setVisible(false);
			pn_ChangePwd.setVisible(false); 
			 
			
		}
	}
	

	private void initializeCorp(){
		// CORPORATE Update Form

		cName.setText(u.getName());
		cRegNum.setText(u.getNric());  // REG_num = NRIC (10char) 
		cUsername.setText(u.getUsername());
		cAddress.setText(u.getAddress());
		cEmail.setText(u.getEmail());
		cContactNum.setText(Integer.toString(u.getContact_no()));
		pn_ind.setVisible(false);
		pn_corp.setVisible(true);
		return;
	}
	
	private void initializeIndividual(){
		// INDIVIDUAL Update Form
		
		iName.setText(u.getName());
		iNric.setText(u.getNric());
		iAddress.setText(u.getAddress());
		iGender.setText(Character.toString(u.getGender()));
		iRace.setText(u.getRace_status_code());
		iEmail.setText(u.getEmail());
		iUsername.setText(u.getUsername());
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
		iDOB.setText(sdf.format(u.getDob()));
		iContactNum.setText(Integer.toString(u.getContact_no()));
		pn_ind.setVisible(true);
		pn_corp.setVisible(false);
		return;
	}
	

	
	private JLabel getLblCustomerProfile() {
		if (lblCustomerProfile == null) {
			lblCustomerProfile = new JLabel("Customer Profile");
			lblCustomerProfile.setBounds(79, 11, 136, 14);
		}
		return lblCustomerProfile;
	}
	private JPanel getPn_ind() {
		
		if (pn_ind == null) {
			pn_ind = new JPanel();
			pn_ind.setBounds(48, 41, 433, 431);
			pn_ind.setLayout(null);
			pn_ind.add(getLbl_iName());
			pn_ind.add(getiName());
			pn_ind.add(getNRIC());
			pn_ind.add(getlbl_Nric());
			pn_ind.add(getGender());
			pn_ind.add(getlbl_Gender());
			pn_ind.add(getlbl_Race());
			pn_ind.add(getRace());
			pn_ind.add(getResidentAdd());
			pn_ind.add(getIAddress());
			pn_ind.add(getlbl_Email());
			pn_ind.add(getIEmail());
			pn_ind.add(getUsername());
			pn_ind.add(getlbl_Username());
			pn_ind.add(getlbl_Password());
			pn_ind.add(getLbl_iDOB());
			pn_ind.add(getIDOB());
			pn_ind.add(getLbl_iContactNum());
			pn_ind.add(getIContactNum());
			pn_ind.add(getBn_UpdateiPwd());
		}
		return pn_ind;
	}

	private JPanel getPn_corp() {
		if (pn_corp == null) {
			pn_corp = new JPanel();
			pn_corp.setBounds(34, 36, 466, 431);
			pn_corp.setLayout(null);
			pn_corp.add(getlbl_cName());
			pn_corp.add(getcName());
			pn_corp.add(getLabel_Username());
			pn_corp.add(getLbl_cPassword());
			pn_corp.add(getLbl_cRegNum());
			pn_corp.add(getLbl_cAddress());
			pn_corp.add(getLabel_Email());
			pn_corp.add(getCUsername());
			pn_corp.add(getCRegNum());
			pn_corp.add(getCAddress());
			pn_corp.add(getCEmail());
			pn_corp.add(getLbl_cContactNum());
			pn_corp.add(getCContactNum());
			pn_corp.add(getBtnUpdateCPsd());
		}
		return pn_corp;
	}
	private JLabel getLbl_iName() {
		if (lbl_iName == null) {
			lbl_iName = new JLabel("Name");
			lbl_iName.setBounds(10, 22, 46, 14);
		}
		return lbl_iName;
	}
	private JLabel getlbl_cName() {
		if (lbl_cName == null) {
			lbl_cName = new JLabel("Company Name");
			lbl_cName.setBounds(34, 28, 80, 14);
		}
		return lbl_cName;
	}
	private JLabel getiName() {
		if (iName == null) {
			iName = new JLabel("iName");
			iName.setBounds(175, 22, 114, 14);
		}
		return iName;
	}
	private JLabel getcName() {
		if (cName == null) {
			cName = new JLabel("cName");
			cName.setBounds(221, 28, 46, 14);
		}
		return cName;
	}
	private JLabel getNRIC() {
		if (lbl_iNric == null) {
			lbl_iNric = new JLabel("NRIC");
			lbl_iNric.setBounds(10, 133, 46, 14);
		}
		return lbl_iNric;
	}
	private JLabel getlbl_Nric() {
		if (iNric == null) {
			iNric = new JLabel("iNRIC");
			iNric.setBounds(175, 133, 100, 14);
		}
		return iNric;
	}
	private JLabel getlbl_Gender() {
		if (lbl_iGender == null) {
			lbl_iGender = new JLabel("Gender ");
			lbl_iGender.setBounds(10, 205, 46, 14);
		}
		return lbl_iGender;
	}
	private JLabel getGender() {
		if (iGender == null) {
			iGender = new JLabel("iGender");
			iGender.setBounds(175, 205, 100, 14);
		}
		return iGender;
	}
	private JLabel getlbl_Race() {
		if (lbl_iRace == null) {
			lbl_iRace = new JLabel("Race");
			lbl_iRace.setBounds(10, 242, 46, 14);
		}
		return lbl_iRace;
	}
	private JLabel getRace() {
		if (iRace == null) {
			iRace = new JLabel("iRace");
			iRace.setBounds(175, 242, 100, 14);
		}
		return iRace;
	}
	private JLabel getResidentAdd() {
		if (lbl_iResidentialAdd == null) {
			lbl_iResidentialAdd = new JLabel("Residential Address");
			lbl_iResidentialAdd.setBounds(10, 311, 94, 14);
		}
		return lbl_iResidentialAdd;
	}
	public JTextField getIAddress() {
		if (iAddress == null) {
			iAddress = new JTextField();
			iAddress.setBounds(175, 307, 214, 20);
			iAddress.setColumns(10);
		}
		return iAddress;
	}
	private JLabel getlbl_Email() {
		if (lbl_iEmail == null) {
			lbl_iEmail = new JLabel("Email ");
			lbl_iEmail.setBounds(10, 347, 46, 14);
		}
		return lbl_iEmail;
	}
	public JTextField getIEmail() {
		if (iEmail == null) {
			iEmail = new JTextField();
			iEmail.setBounds(175, 341, 214, 20);
			iEmail.setColumns(10);
		}
		return iEmail;
	}
	private JLabel getlbl_Username() {
		if (lbl_iUsername == null) {
			lbl_iUsername = new JLabel("Username");
			lbl_iUsername.setBounds(10, 57, 62, 14);
		}
		return lbl_iUsername;
	}
	private JLabel getUsername() {
		if (iUsername == null) {
			iUsername = new JLabel("iUsername");
			iUsername.setBounds(175, 57, 114, 14);
		}
		return iUsername;
	}
	private JLabel getlbl_Password() {
		if (lbl_iPassword == null) {
			lbl_iPassword = new JLabel("Password");
			lbl_iPassword.setBounds(10, 93, 46, 14);
		}
		return lbl_iPassword;
	}
	private JLabel getLabel_Username() {
		if (lbl_cUsername == null) {
			lbl_cUsername = new JLabel("Username");
			lbl_cUsername.setBounds(34, 69, 80, 14);
		}
		return lbl_cUsername;
	}
	private JLabel getLbl_cPassword() {
		if (lbl_cPassword == null) {
			lbl_cPassword = new JLabel("Password");
			lbl_cPassword.setBounds(34, 111, 46, 14);
		}
		return lbl_cPassword;
	}
	private JLabel getLbl_cRegNum() {
		if (lbl_cRegNum == null) {
			lbl_cRegNum = new JLabel("Register Number");
			lbl_cRegNum.setBounds(34, 148, 80, 14);
		}
		return lbl_cRegNum;
	}
	private JLabel getLbl_cAddress() {
		if (lbl_cAddress == null) {
			lbl_cAddress = new JLabel("Residential Address");
			lbl_cAddress.setBounds(34, 221, 94, 14);
		}
		return lbl_cAddress;
	}
	private JLabel getLabel_Email() {
		if (lbl_cEmail == null) {
			lbl_cEmail = new JLabel("Email ");
			lbl_cEmail.setBounds(34, 259, 46, 14);
		}
		return lbl_cEmail;
	}
	private JLabel getLbl_iDOB() {
		if (lbl_iDOB == null) {
			lbl_iDOB = new JLabel("Date of Birth");
			lbl_iDOB.setBounds(10, 169, 74, 14);
		}
		return lbl_iDOB;
	}
	private JLabel getIDOB() {
		if (iDOB == null) {
			iDOB = new JLabel("iDOB");
			iDOB.setBounds(175, 169, 100, 14);

		}
	return iDOB;
	}
	
	public String getIDOB1(){
		Date date = (Date) Calendar.getInstance().getTime();
		DateFormat df = new SimpleDateFormat("dd/mm/yyyy");
		String reportDate = df.format(date);
		return reportDate;
	}
	
	
	private JLabel getCUsername() {
		if (cUsername == null) {
			cUsername = new JLabel("cUsername");
			cUsername.setBounds(221, 69, 46, 14);
		}
		return cUsername;
	}
	private JLabel getCRegNum() {
		if (cRegNum == null) {
			cRegNum = new JLabel("cRegNum");
			cRegNum.setBounds(221, 148, 46, 14);
		}
		return cRegNum;
	}
	public JTextField getCAddress() {
		if (cAddress == null) {
			cAddress = new JTextField();
			cAddress.setBounds(221, 218, 214, 20);
			cAddress.setColumns(10);
		}
		return cAddress;
	}
	public JTextField getCEmail() {
		if (cEmail == null) {
			cEmail = new JTextField();
			cEmail.setBounds(221, 256, 214, 20);
			cEmail.setColumns(10);
		}
		return cEmail;
	}
	//BUTTON TO UPDATE Profile (FROM THE FORM) 
	private JButton getBtnUpdateProfile() {
		if (btnUpdateProfile == null) {
			btnUpdateProfile = new JButton("Update Profile");
			btnUpdateProfile.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					boolean valid = false;
					valid = validateForm();
					if(valid == true){
						control.updateMembership();
						JOptionPane.showMessageDialog(frame, "Account Updated");
					}
				}
			});
			btnUpdateProfile.setBounds(60, 506, 119, 23);
		}
		return btnUpdateProfile;
	}
	private JLabel getLbl_iContactNum() {
		if (lbl_iContactNum == null) {
			lbl_iContactNum = new JLabel("Contact Number");
			lbl_iContactNum.setBounds(10, 274, 94, 14);
		}
		return lbl_iContactNum;
	}
	public JTextField getIContactNum() {
		if (iContactNum == null) {
			iContactNum = new JTextField();
			iContactNum.setBounds(175, 267, 122, 20);
			iContactNum.setColumns(10);
		}
		return iContactNum;
	}
	private JLabel getLbl_cContactNum() {
		if (lbl_cContactNum == null) {
			lbl_cContactNum = new JLabel("Contact Number");
			lbl_cContactNum.setBounds(34, 185, 94, 14);
		}
		return lbl_cContactNum;
	}
	public JTextField getCContactNum() {
		if (cContactNum == null) {
			cContactNum = new JTextField();
			cContactNum.setColumns(10);
			cContactNum.setBounds(221, 187, 100, 20);
		}
		return cContactNum;
	}
	private JPanel getPn_ChangePwd() {
		if (pn_ChangePwd == null) {
			pn_ChangePwd = new JPanel();
			pn_ChangePwd.setBounds(10, 115, 443, 245);
			GridBagLayout gbl_pn_ChangePwd = new GridBagLayout();
			gbl_pn_ChangePwd.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
			gbl_pn_ChangePwd.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
			gbl_pn_ChangePwd.columnWeights = new double[]{0.0, 0.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
			gbl_pn_ChangePwd.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
			pn_ChangePwd.setLayout(gbl_pn_ChangePwd);
			GridBagConstraints gbc_lblCurrentPassowrd = new GridBagConstraints();
			gbc_lblCurrentPassowrd.anchor = GridBagConstraints.EAST;
			gbc_lblCurrentPassowrd.insets = new Insets(0, 0, 5, 5);
			gbc_lblCurrentPassowrd.gridx = 1;
			gbc_lblCurrentPassowrd.gridy = 2;
			pn_ChangePwd.add(getLblCurrentPassowrd(), gbc_lblCurrentPassowrd);
			GridBagConstraints gbc_PF_CurrentPwd = new GridBagConstraints();
			gbc_PF_CurrentPwd.gridwidth = 2;
			gbc_PF_CurrentPwd.insets = new Insets(0, 0, 5, 5);
		gbc_PF_CurrentPwd.fill = GridBagConstraints.HORIZONTAL;
			gbc_PF_CurrentPwd.gridx = 2;
			gbc_PF_CurrentPwd.gridy = 2;
			pn_ChangePwd.add(getPF_CurrentPwd(), gbc_PF_CurrentPwd);
			GridBagConstraints gbc_lblNewPwd = new GridBagConstraints();
			gbc_lblNewPwd.anchor = GridBagConstraints.EAST;
			gbc_lblNewPwd.fill = GridBagConstraints.VERTICAL;
			gbc_lblNewPwd.insets = new Insets(0, 0, 5, 5);
			gbc_lblNewPwd.gridx = 1;
			gbc_lblNewPwd.gridy = 4;
			pn_ChangePwd.add(getLblNewPwd(), gbc_lblNewPwd);
			GridBagConstraints gbc_PF_NewPwd = new GridBagConstraints();
			gbc_PF_NewPwd.gridwidth = 2;
			gbc_PF_NewPwd.insets = new Insets(0, 0, 5, 5);
			gbc_PF_NewPwd.fill = GridBagConstraints.HORIZONTAL;
			gbc_PF_NewPwd.gridx = 2;
			gbc_PF_NewPwd.gridy = 4;
			pn_ChangePwd.add(getPF_NewPwd(), gbc_PF_NewPwd);
			GridBagConstraints gbc_lblConfirmPwd = new GridBagConstraints();
			gbc_lblConfirmPwd.insets = new Insets(0, 0, 5, 5);
			gbc_lblConfirmPwd.gridx = 1;
			gbc_lblConfirmPwd.gridy = 6;
			pn_ChangePwd.add(getLblConfirmPwd(), gbc_lblConfirmPwd);
			GridBagConstraints gbc_PF_CfmPwd = new GridBagConstraints();
			gbc_PF_CfmPwd.gridwidth = 2;
			gbc_PF_CfmPwd.insets = new Insets(0, 0, 5, 5);
			gbc_PF_CfmPwd.fill = GridBagConstraints.HORIZONTAL;
			gbc_PF_CfmPwd.gridx = 2;
			gbc_PF_CfmPwd.gridy = 6;
			pn_ChangePwd.add(getPF_CfmPwd(), gbc_PF_CfmPwd);
			GridBagConstraints gbc_Bn_UpdatePwd = new GridBagConstraints();
			gbc_Bn_UpdatePwd.insets = new Insets(0, 0, 5, 5);
			gbc_Bn_UpdatePwd.gridx = 2;
			gbc_Bn_UpdatePwd.gridy = 8;
			pn_ChangePwd.add(getBn_UpdatePwd(), gbc_Bn_UpdatePwd);
			GridBagConstraints gbc_bn_cancelPwd = new GridBagConstraints();
			gbc_bn_cancelPwd.insets = new Insets(0, 0, 5, 5);
			gbc_bn_cancelPwd.gridx = 3;
			gbc_bn_cancelPwd.gridy = 8;
			pn_ChangePwd.add(getBn_cancelPwd(), gbc_bn_cancelPwd);
		}
		return pn_ChangePwd;
	}
	private JLabel getLblCurrentPassowrd() {
		if (lblCurrentPassowrd == null) {
			lblCurrentPassowrd = new JLabel("Current Password: ");
		}
		return lblCurrentPassowrd;
	} 
	private JLabel getLblNewPwd() {
		if (lblNewPwd == null) {
			lblNewPwd = new JLabel("New Password: ");
		}
		return lblNewPwd;
	}
	private JLabel getLblConfirmPwd() {
		if (lblConfirmPwd == null) {
			lblConfirmPwd = new JLabel("Confirm Password : ");
		}
		return lblConfirmPwd;
	}
	private JPasswordField getPF_CurrentPwd() {
		if (PF_CurrentPwd == null) {
			PF_CurrentPwd = new JPasswordField();
		}
		return PF_CurrentPwd;
	}
	public JPasswordField getPF_NewPwd() {
		if (PF_NewPwd == null) {
			PF_NewPwd = new JPasswordField();
		}
		return PF_NewPwd;
	}
	private JPasswordField getPF_CfmPwd() {
		if (PF_CfmPwd == null) {
			PF_CfmPwd = new JPasswordField();
		}
		return PF_CfmPwd;
	}
	
	

	
	public boolean validateForm(){
		boolean valid = false;
		
		if(u.getCustomerUserType().equals("CORPORATE")){
			
			try{
				int num = Integer.parseInt(cContactNum.getText());
					
				if(cContactNum.getText().length()!=8){
					//Prompt error
					JOptionPane.showMessageDialog(null, "Invalid contact number", "Error message",  JOptionPane.ERROR_MESSAGE);
					cContactNum.setBorder(BorderFactory.createLineBorder(Color.RED, 2));
				}
				else {
					valid = true;
					cContactNum.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
				}
			}
			catch(Exception ex){
				//prompt contact number must be numeric
				JOptionPane.showMessageDialog(null, "Invalid contact number", "Error message",  JOptionPane.ERROR_MESSAGE);
				cContactNum.setBorder(BorderFactory.createLineBorder(Color.RED, 2));
			}
			
		}else if(u.getCustomerUserType().equals("INDIVIDUAL")){
			try{
				int num = Integer.parseInt(iContactNum.getText());
				if(iContactNum.getText().length()!=8){
					JOptionPane.showMessageDialog(null, "Error message", "Invalid contact number", JOptionPane.ERROR_MESSAGE);
					iContactNum.setBorder(BorderFactory.createLineBorder(Color.RED, 2));
				}
				else {
					valid = true;
					iContactNum.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
				}
			}catch(Exception ex){
				JOptionPane.showMessageDialog(null, "Error message", "Invalid contact number", JOptionPane.ERROR_MESSAGE);			
				iContactNum.setBorder(BorderFactory.createLineBorder(Color.RED, 2));
			}
		}
		return valid;
	}
	

	
	public boolean validatePwd(){
		boolean valid = false;
		String pwd = (new String(PF_CurrentPwd.getPassword()));
		String newPassword = (new String (PF_NewPwd.getPassword()));
		String CfmPassword =  (new String (PF_CfmPwd.getPassword()));
		if(!pwd.equals(u.getPassword())){
			System.out.print(u.getPassword());
			PF_CurrentPwd.setBorder(BorderFactory.createLineBorder(Color.RED, 2));
			JOptionPane.showMessageDialog(frame, "Wrong Current password is entered. Please try again ");
			
		}
		//(idSU.equals("") || pwdSU.equals(""))
		else if (newPassword.equals("")||CfmPassword.equals("")) {
			JOptionPane.showMessageDialog(frame, "Please fill up all fields.");
			PF_NewPwd.setBorder(BorderFactory.createLineBorder(Color.RED, 2));
			PF_CfmPwd.setBorder(BorderFactory.createLineBorder(Color.RED, 2));
		}
		else{
			
			
			if((newPassword).equals(CfmPassword)==false){

				//**Take Note :: Chances of Encap error **// 
				JOptionPane.showMessageDialog(frame, "Password mismatch. Please try again");
				PF_NewPwd.setBorder(BorderFactory.createLineBorder(Color.RED, 2));
				PF_CfmPwd.setBorder(BorderFactory.createLineBorder(Color.RED, 2));

				
			}else{
				valid = true;
				PF_CurrentPwd.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
				PF_NewPwd.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
				PF_CfmPwd.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));

			}
		}
		return valid;
	}


	public void setPF_CurrentPwd(JPasswordField pF_CurrentPwd) {
		PF_CurrentPwd = pF_CurrentPwd;
	}

	public void setPF_NewPwd(JPasswordField pF_NewPwd) {
		PF_NewPwd = pF_NewPwd;
	}

	public void setPF_CfmPwd(JPasswordField pF_CfmPwd) {
		PF_CfmPwd = pF_CfmPwd;
	}

	private void resetPasswordForm(){
		PF_CurrentPwd.setText("");
		PF_NewPwd.setText("");
		PF_CfmPwd.setText("");
		return;
	}
	private JButton getBtnDeleteAccount() {
		if (btnDeleteAccount == null) {
			btnDeleteAccount = new JButton("Delete Account");
			btnDeleteAccount.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					control.deactivate();
					JOptionPane.showMessageDialog(frame,
						    "Successfully deleted");
					Main.frame.dispose();
				}
			});
			btnDeleteAccount.setBounds(202, 506, 118, 23);
		}
		return btnDeleteAccount;
	}
	
	
	
	
	/*****BUTTON ACTION*****/
	
	//CLOSE UpdatePasswordPanel
	private JButton getBn_cancelPwd() {
		if (bn_cancelPwd == null) {
			bn_cancelPwd = new JButton("Cancel");
			bn_cancelPwd.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					pn_ChangePwd.setVisible(false); 
					resetPasswordForm();
					
					
					if(u.getCustomerUserType().equals("CORPORATE")){
						initializeCorp();
			 
						pn_ind.setVisible(false);
						pn_corp.setVisible(true);
						btnUpdateProfile.setVisible(true);
						
					}else if(u.getCustomerUserType().equals("INDIVIDUAL")){
						
						initializeIndividual();
						pn_ind.setVisible(true);
						pn_corp.setVisible(false);
						btnUpdateProfile.setVisible(true);
				
					
						
					}
				}
			});
		}
		return bn_cancelPwd;
	}
	
	//Button to DIRECT TO the IND.UpdatePasswordForm
	private JButton getBn_UpdateiPwd() {
		if (bn_UpdateiPwd == null) {
			bn_UpdateiPwd = new JButton("Update Password");
			bn_UpdateiPwd.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					
					pn_ChangePwd.setVisible(true);
					pn_ind.setVisible(false);
					btnUpdateProfile.setVisible(false);

					
				}
			});
			bn_UpdateiPwd.setBounds(167, 89, 122, 23);
		}
		return bn_UpdateiPwd;
	}
	
	//Button to DIRECT TO the CORP.UpdatePasswordForm
	private JButton getBtnUpdateCPsd() {
		if (btnUpdateCPsd == null) {
			btnUpdateCPsd = new JButton("Update Password");
			btnUpdateCPsd.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					pn_ChangePwd.setVisible(true);
					pn_corp.setVisible(false);
					btnUpdateProfile.setVisible(false);
					
				}
			});
			btnUpdateCPsd.setBounds(218, 107, 122, 23);
		}
		return btnUpdateCPsd;
	}
	
	//BUTTON TO UPDATE PASSWORD (FROM UpdatePasswordForm)
		private JButton getBn_UpdatePwd() {
			if (Bn_UpdatePwd == null) {
				Bn_UpdatePwd = new JButton("Update Password");
				Bn_UpdatePwd.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						boolean valid = false; 
						valid = validatePwd();
						if(valid == true){
							control.updatePassword();
							// DISPLAY SUCCESSFUL 
							JOptionPane.showMessageDialog(frame,"Password successfully updated.");
							
							if(u.getCustomerUserType().equals("CORPORATE")){
								pn_ind.setVisible(false);
								pn_corp.setVisible(true);
								pn_ChangePwd.setVisible(false); 

							}else if(u.getCustomerUserType().equals("INDIVIDUAL")){
								initializeIndividual();
								pn_ind.setVisible(true);
								pn_corp.setVisible(false);
								pn_ChangePwd.setVisible(false); 
							}	
						}
						else{
							//show error
						}
					}
				});
			}
			return Bn_UpdatePwd;
		}

	
}
